/*
 * AbstractDAO.java
 *
 * Created on June 21, 2007, 8:05 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package jhub.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author dbotelho
 */
public abstract class AbstractDAO {
    protected Connection conn;
    private final PreparedStatement selectAllUsersStatement;
    
    
    protected int nextValue(String sequence) throws SQLException{
        selectAllUsersStatement.setString(1,sequence);
         ResultSet rs = selectAllUsersStatement.executeQuery();
         rs.next();
         return rs.getInt("nextval");
    }
    
    /** Creates a new instance of AbstractDAO */
    public AbstractDAO(Connection conn) throws SQLException {
       this.conn = conn;
       this.selectAllUsersStatement = conn.prepareStatement("SELECT nextval(?)");
        
    }
    
}
